/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tecbooks;
import java.awt.Color;
import javax.swing.JOptionPane;

/**
 *
 * @author ferreira
 */
public class Reserva extends javax.swing.JFrame {

    /**
     * Creates new form Reserva
     */
    public Reserva() {
        initComponents();
        setTitle("Reserva");
        this.getContentPane().setBackground(Color.CYAN);      
        this.setVisible(true);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblIdClienteReserva = new javax.swing.JLabel();
        txtIdClienteReserva = new javax.swing.JFormattedTextField();
        lblIdLivroReserva = new javax.swing.JLabel();
        txtIdLivroReserva = new javax.swing.JFormattedTextField();
        lblDataSaida = new javax.swing.JLabel();
        lblDataEntrega = new javax.swing.JLabel();
        btnOkLocacao = new javax.swing.JButton();
        btnCancelarLocacao = new javax.swing.JButton();
        lblAvisoLocacao = new javax.swing.JLabel();
        cmbDiaLocacaoSaida = new javax.swing.JComboBox();
        cmbMesLocacaoSaida = new javax.swing.JComboBox();
        cmbDiaLocacaoEntrega = new javax.swing.JComboBox();
        cmbMesLocacaoEntrega = new javax.swing.JComboBox();
        cmbAnoLocacaosaida = new javax.swing.JComboBox();
        cmbAnoLocacaoEntrega = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        lblIdClienteReserva.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        lblIdClienteReserva.setText("ID Cliente*:");

        txtIdClienteReserva.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));

        lblIdLivroReserva.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        lblIdLivroReserva.setText("ID Livro*:");

        txtIdLivroReserva.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));

        lblDataSaida.setBackground(new java.awt.Color(255, 255, 255));
        lblDataSaida.setFont(new java.awt.Font("Tahoma", 1, 15)); // NOI18N
        lblDataSaida.setText("Data de saida(dd/mm/aaaa):");

        lblDataEntrega.setFont(new java.awt.Font("Tahoma", 1, 15)); // NOI18N
        lblDataEntrega.setText("Data de entrega(dd/mm/aaaa):");

        btnOkLocacao.setText("OK");
        btnOkLocacao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOkLocacaoActionPerformed(evt);
            }
        });

        btnCancelarLocacao.setText("Cancelar");
        btnCancelarLocacao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarLocacaoActionPerformed(evt);
            }
        });

        lblAvisoLocacao.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        lblAvisoLocacao.setForeground(new java.awt.Color(255, 0, 0));

        cmbDiaLocacaoSaida.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "  ", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        cmbMesLocacaoSaida.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "  ", "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro" }));

        cmbDiaLocacaoEntrega.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "  ", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        cmbMesLocacaoEntrega.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "  ", "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro" }));

        cmbAnoLocacaosaida.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "  ", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020" }));

        cmbAnoLocacaoEntrega.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "  ", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020" }));

        jButton1.setText("Limpar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(34, 34, 34)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(lblIdLivroReserva)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(txtIdLivroReserva))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(lblIdClienteReserva)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(txtIdClienteReserva, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(lblDataEntrega)
                            .addComponent(lblDataSaida)
                            .addComponent(lblAvisoLocacao, javax.swing.GroupLayout.PREFERRED_SIZE, 318, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(76, 76, 76)
                        .addComponent(cmbDiaLocacaoSaida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(cmbMesLocacaoSaida, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(cmbAnoLocacaosaida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(76, 76, 76)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cmbDiaLocacaoEntrega, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnOkLocacao))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(cmbMesLocacaoEntrega, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(cmbAnoLocacaoEntrega, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(jButton1)
                                .addGap(18, 18, 18)
                                .addComponent(btnCancelarLocacao)
                                .addGap(22, 22, 22)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblIdClienteReserva, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtIdClienteReserva, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblIdLivroReserva)
                    .addComponent(txtIdLivroReserva, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(36, 36, 36)
                .addComponent(lblDataSaida, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmbDiaLocacaoSaida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmbMesLocacaoSaida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmbAnoLocacaosaida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(29, 29, 29)
                .addComponent(lblDataEntrega)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmbDiaLocacaoEntrega, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmbMesLocacaoEntrega, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmbAnoLocacaoEntrega, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(44, 44, 44)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnOkLocacao)
                    .addComponent(btnCancelarLocacao)
                    .addComponent(jButton1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblAvisoLocacao, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(31, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnOkLocacaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkLocacaoActionPerformed
        if (txtIdLivroReserva.getText().isEmpty() || txtIdClienteReserva.getText().isEmpty() || cmbDiaLocacaoSaida.getSelectedItem().equals("  ") ||
            cmbMesLocacaoSaida.getSelectedItem().equals("  ")||cmbAnoLocacaosaida.getSelectedItem().equals("  ")||cmbDiaLocacaoEntrega.getSelectedItem().equals("  ")
            ||cmbMesLocacaoEntrega.getSelectedItem().equals("  ")||cmbAnoLocacaoEntrega.getSelectedItem().equals("  ")) {
            lblAvisoLocacao.setText("Preencha os campos obrigatórios!");

        } else {
            JOptionPane.showMessageDialog(null, "Reserva realizada!");   
            dispose();
            // TODO add your handling code here:
        }
    }//GEN-LAST:event_btnOkLocacaoActionPerformed

    private void btnCancelarLocacaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarLocacaoActionPerformed
        dispose();
               // TODO add your handling code here:
    }//GEN-LAST:event_btnCancelarLocacaoActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
       txtIdClienteReserva.setText(" ");
       txtIdLivroReserva.setText(" ");
       cmbAnoLocacaoEntrega.setSelectedIndex(0);
       cmbAnoLocacaosaida.setSelectedIndex(0);
       cmbDiaLocacaoEntrega.setSelectedIndex(0);
       cmbMesLocacaoEntrega.setSelectedIndex(0);
       cmbDiaLocacaoSaida.setSelectedIndex(0);
       cmbMesLocacaoSaida.setSelectedIndex(0);
       // TODO add your handling code here:
    }//GEN-LAST:event_jButton1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Reserva.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Reserva.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Reserva.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Reserva.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Reserva().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelarLocacao;
    private javax.swing.JButton btnOkLocacao;
    private javax.swing.JComboBox cmbAnoLocacaoEntrega;
    private javax.swing.JComboBox cmbAnoLocacaosaida;
    private javax.swing.JComboBox cmbDiaLocacaoEntrega;
    private javax.swing.JComboBox cmbDiaLocacaoSaida;
    private javax.swing.JComboBox cmbMesLocacaoEntrega;
    private javax.swing.JComboBox cmbMesLocacaoSaida;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel lblAvisoLocacao;
    private javax.swing.JLabel lblDataEntrega;
    private javax.swing.JLabel lblDataSaida;
    private javax.swing.JLabel lblIdClienteReserva;
    private javax.swing.JLabel lblIdLivroReserva;
    private javax.swing.JFormattedTextField txtIdClienteReserva;
    private javax.swing.JFormattedTextField txtIdLivroReserva;
    // End of variables declaration//GEN-END:variables
}
